
extends Node

func _input(event):
	if event.is_class("InputEventKey"):
		if (!Player.docked && event.is_action_pressed("time_speedup")):
			Player.time_speedup = !Player.time_speedup

func _process(delta):
	#awkward
	Player.time_scale += delta*clamp(Player.max_time_scale*int(Player.time_speedup)+(1-int(Player.time_speedup))-Player.time_scale,-2.0,1.0)
	HUD.get_node("TimeScale").set_value(Player.time_scale)
	if (Player.time_scale<1.01):
		HUD.get_node("TimeScale").modulate.a = clamp(HUD.get_node("TimeScale").modulate.a*(1-2.0*delta),0.0,1.0)
	else:
		HUD.get_node("TimeScale").modulate.a = clamp(HUD.get_node("TimeScale").modulate.a*(1+4.0*delta),0.1,1.0)
	Engine.set_time_scale(Player.time_scale)

func _ready():
	set_process_input(true)
	set_process(true)
